package com.vladimirkolarevic.eventplanner.tapestry.components;

import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.RequestGlobals;

import com.vladimirkolarevic.eventplanner.User;
import com.vladimirkolarevic.eventplanner.tapestry.pages.EventInfo;
import com.vladimirkolarevic.eventplanner.tapestry.pages.Index;
import com.vladimirkolarevic.eventplanner.tapestry.pages.UserInfo;

public class Layout {

	@InjectPage
	private EventInfo eventinfo;
	
	@Inject
	private RequestGlobals requestGlobals;
	
	@ApplicationState
	private User user;
	private boolean userExists;
	
	
	@OnEvent(component="logout")
	Object logOut(){
		
		
		
		requestGlobals.getHTTPServletRequest().getSession().invalidate();
		
		return Index.class;
	}
	
	public boolean isUserExists() {
		return userExists;
	}
	
	@OnEvent(component="profile")
	Object profile(){
		
		return UserInfo.class;
	}
	
}
